using EOSDigital.SDK;
using System;

namespace EOSDigital.API
{
	public class CameraFileEntry : IDisposable
	{
		protected IntPtr Ref;

		protected internal bool IsDisposed;

		public IntPtr Reference
		{
			get
			{
				return this.Ref;
			}
		}

		public string Name
		{
			get;
			protected set;
		}

		public bool IsFolder
		{
			get;
			protected set;
		}

		public bool IsVolume
		{
			get;
			protected set;
		}

		public CameraFileEntry[] Entries
		{
			get;
			protected internal set;
		}

		protected internal CameraFileEntry(IntPtr Ref, string Name, bool IsFolder, bool IsVolume)
		{
			this.Ref = Ref;
			this.Name = Name;
			this.IsFolder = IsFolder;
			this.IsVolume = IsVolume;
		}

		~CameraFileEntry()
		{
			this.Dispose(false);
		}

		public void Dispose()
		{
			this.Dispose(true);
			GC.SuppressFinalize(this);
		}

		public void DisposeAll()
		{
			this.Dispose();
			if (this.Entries != null)
			{
				for (int i = 0; i < this.Entries.Length; i++)
				{
					this.Entries[i].DisposeAll();
				}
			}
		}

		protected virtual void Dispose(bool managed)
		{
			if (!this.IsDisposed)
			{
				if (this.Reference != IntPtr.Zero)
				{
					CanonSDK.EdsRelease(this.Reference);
				}
				this.IsDisposed = true;
			}
		}

		protected internal virtual void SetThumb(IntPtr stream)
		{
		}

		public static bool operator ==(CameraFileEntry x, CameraFileEntry y)
		{
			if (object.ReferenceEquals(x, y))
			{
				return true;
			}
			if ((object)x != null && (object)y != null)
			{
				return x.Reference == y.Reference;
			}
			return false;
		}

		public static bool operator !=(CameraFileEntry x, CameraFileEntry y)
		{
			return !(x == y);
		}

		public override bool Equals(object obj)
		{
			if (obj.GetType() != base.GetType())
			{
				return false;
			}
			if (object.ReferenceEquals(this, obj))
			{
				return true;
			}
			CameraFileEntry cameraFileEntry = obj as CameraFileEntry;
			if (cameraFileEntry == (CameraFileEntry)null)
			{
				return false;
			}
			return this.Reference == cameraFileEntry.Reference;
		}

		public override int GetHashCode()
		{
			return this.Reference.ToInt64().GetHashCode();
		}
	}
}
